package com.wj.tool.common.exception.message;

import org.apache.commons.lang3.StringUtils;

public class ServiceMessage extends ApplicationMessage {
    public static final int DUPLICATE_VALUE_CODE = 10201;
    public static final String DUPLICATE_VALUE_10201_MESSAGE = " Duplicate value ";
    public static final int EMPTY_VALUE_CODE = 10202;
    public static final String EMPTY_VALUE_10202_MESSAGE = "Empty value";
    public static final int ILLEGAL_VALUE_CODE = 10203;
    public static final String ILLEGAL_VALUE_10203_MESSAGE = " Illegal value";

    public static ServiceMessage duplicateValue(String message) {
        return new ServiceMessage(10201, StringUtils.isEmpty(message) ? " Duplicate value " : message, MessageType.SERVICE);
    }

    public static ServiceMessage emptyValue(String message) {
        return new ServiceMessage(10202, StringUtils.isEmpty(message) ? "Empty value" : message, MessageType.SERVICE);
    }

    public static ServiceMessage illegalValue(String message) {
        return new ServiceMessage(10203, StringUtils.isEmpty(message) ? " Illegal value" : message, MessageType.SERVICE);
    }

    private ServiceMessage(int code, String message, MessageType type) {
        super(code, message, type);
    }
}